package self.hoy.demo.grainmall.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import self.hoy.demo.common.valid.Add;
import self.hoy.demo.common.valid.ListValue;
import self.hoy.demo.common.valid.Switch;
import self.hoy.demo.common.valid.Update;

import javax.validation.constraints.*;

/**
 * 品牌
 * 
 * @author Hoy
 * @email xxx@gmail.com
 * @date 2020-07-04 19:01:00
 */
@Data
@TableName("pms_brand")
public class Brand implements Serializable {
	private static final long serialVersionUID = 5740730721550486364L;

	/**
	 * 品牌id
	 */
	@Null(message = "新增不能指定品牌id", groups = {Add.class})
	@NotNull(message = "修改必须指定品牌id", groups = {Update.class, Switch.class})
	@TableId
	private Long brandId;

	/**
	 * 品牌名
	 */
	@NotBlank(message = "请填写品牌名称", groups = {Add.class, Update.class})
	private String name;

	/**
	 * 品牌logo地址
	 */
	@NotEmpty(message = "请上传品牌logo图片", groups = {Add.class})
	@URL(message = "logo必须是网络图片链接", groups = {Add.class, Update.class})
	private String logo;

	/**
	 * 介绍
	 */
	@NotBlank(message = "请填写品牌介绍", groups = {Add.class, Update.class})
	private String descript;

	/**
	 * 显示状态[0-不显示；1-显示]
	 */
	@NotNull(message = "请选择显示状态", groups = {Add.class, Update.class, Switch.class})
//	@Min(value = 0, groups = {Add.class, Update.class})
//	@Max(value = 1, groups = {Add.class, Update.class})
	@ListValue(values = {0, 1}, groups = {Add.class, Update.class, Switch.class})
	private Integer showStatus;

	/**
	 * 检索首字母
	 */
	@NotEmpty(message = "请填写首字母", groups = {Add.class, Update.class})
	@Pattern(regexp = "^[a-zA-X]$", message = "必须是一个字母", groups = {Add.class, Update.class})
	private String firstLetter;

	/**
	 * 排序
	 */
	@NotNull(message = "请填写排序", groups = {Add.class, Update.class})
	@Min(value = 0, groups = {Add.class, Update.class})
	private Integer sort;

}
